<%--
  Created by IntelliJ IDEA.
  User: SXT
  Date: 2020/6/24
  Time: 15:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>主持人管理页面</title>
    <base href="<%=request.getContextPath()+"/"%>">
    <%--引入easyui主题的css样式--%>
    <link rel="stylesheet" href="easyui/themes/default/easyui.css">
    <%--引入easyui中图标集的css样式--%>
    <link rel="stylesheet" href="easyui/themes/icon.css">
    <%--引入demo.css--%>
    <link rel="stylesheet" href="easyui/themes/demo.css">
    <%--引入jq中js文件  注意：先引入jq中js在引入easyui中js--%>
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <%--引入easyui中核心js文件--%>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>

    <script type="text/javascript">

         $(function () {
             $('#dg').datagrid({
                 url: 'host/findMoreHost',
                 pagination: true,//设置分页栏展示
                 //rownumbers:true,//设置行号显示
                 pageSize: 5,//设置size的初始大小
                 pageList: [5, 10, 15, 20],// 设置每一页显示条数列表
                 toolbar: "#tb",
                 columns: [[
                     {field: 'strong', title: '权重', width: 70, align: 'center',
                         formatter: function(value,row,index){

                             return  "<input onblur='strongChange(this.value,"+row.hid+")' type='text' value='"+value+"' style='width: 40px'/>";
                         }
                     },
                     {field: 'hname', title: '姓名', width: 70, align: 'center'},
                     {field: 'hphone', title: '手机号', width: 70, align: 'center'},
                     {field: 'starttime', title: '开通时间', width: 70, align: 'center',
                         formatter: function(value,row,index){

                            return  value.year+"-"+value.monthValue+"-"+value.dayOfMonth;
                         }},
                     {field: 'hostPower.hpprice', title: '价格', width: 70, align: 'center',
                         formatter: function(value,row,index){
                             return  row.hostPower.hpprice==null?"新人暂无":row.hostPower.hpprice;
                         }},
                     {field: 'num', title: '订单量', width: 70, align: 'center'},
                     {field: 'abc', title: '折扣', width: 70, align: 'center',
                         formatter: function(value,row,index){
                             return  row.hostPower.hpdiscount==null?"新人暂无":row.hostPower.hpdiscount;
                         }},
                     {field: 'abcd', title: '星推荐', width: 70, align: 'center',
                         formatter: function(value,row,index){
                             return  row.hostPower.hpstart==null?"新人暂无":row.hostPower.hpstart;
                         }},
                     {field: 'status', title: '账号状态', width: 70, align: 'center'},

                     ]]
             });

             /****按照条件查询指定信息****/
             $("#btn1").click(function () {

                   var  arr= $("#fm1").serializeArray();
                   //定义一个空的json对象
                   var  json={};
                   //把数组中内容取出来放到json对象中
                    for(var  i in  arr){
                        json[arr[i].name]=arr[i].value;
                    }

                   $("#dg").datagrid("load",json);

             })
         })
         //修改主持人当前权重
         function strongChange(strong,hid) {

             $.post("host/changeHostStrong",{strong:strong,hid:hid},function (result) {
                   if(result>0){
                       //重新加载数据网格
                       $("#dg").datagrid("reload");
                   }else{
                       $.messager.alert("提示","权重修改失败","error");
                   }
             })

          }
         //添加主持人操作
         function newzhc() {

             //打开当前添加对话框
              $("#dlg").dialog("open").dialog("setTitle","NEW ZCR");
              //清空之前表单内容
             $("#fm").form("clear");
         }
         //提交主持人表单信息
         function savezhr() {
             $.post("host/saveHost",$("#fm").serialize(),function (result) {
                   if(result>0){
                        //关闭当前对话框
                        $("#dlg").dialog("close");
                       //重新加载数据网格
                       $("#dg").datagrid("reload");
                   }

             })


        }

         var  hids="";
        //修改账号状态
        function zcrStatus() {

              var  arr= $("#dg").datagrid("getSelections");

              if(arr.length>0){
                  //打开修改状态对话框
                  $("#zcrStatus_dlg").dialog("open").dialog("setTitle","Change State");
                  //清空表单数据
                  $("#zcrStatus_fm").form("clear");
                  //获得选中行的所有hid   1,2,3,4
                  for(var i in  arr){
                      //防止第一个,的增加
                      if(hids!="") hids+=",";
                      hids+=arr[i].hid;
                  }
              }else{
                  $.messager.alert("提示","请至少选中一行数据","info");
              }



        }
        //提交修改账号状态表单
        function saveZcrStastus() {
             // hids=1,2,3,4
            $.post("host/changeStatus?hids="+hids,$("#zcrStatus_fm").serialize(),function (result) {

                 if(result>0){
                       //重新加载数据网格
                      $("#dg").datagrid("reload");
                      //关闭当前对话框
                     $("#zcrStatus_dlg").dialog("close");
                     //清空hdis
                     hids="";
                 }else{
                     $.messager.alert("提示","账号修改失败","info");
                 }

            })

        }
        
        //批量修改主持人权限
        function zcrRoleB() {

            $("#zcr_dlg").dialog("open");
            
        }
         


    </script>
</head>
<body>

   <div style="width: 800px;height: 600px" class="easyui-panel" title="主持人管理">

             <%--顶部搜索框--%>
             <div style="width: 750px;height: 40px;border: 0px solid red;margin: 0px auto;margin-top: 30px">

                 <form id="fm1">
                     <input class="easyui-textbox" name="hname" data-options="prompt:'姓名'" style="width:100px">
                     <select id="cc" class="easyui-combobox" name="status" style="width:110px;">
                             <option value="">账号状态</option>
                             <option value="正常">正常</option>
                             <option value="禁用">禁用</option>
                     </select>
                     <select id="cc2" class="easyui-combobox" name="strong" style="width:110px;">
                         <option value="">权重排序</option>
                         <option value="asc">升序</option>
                         <option value="desc">降序</option>
                     </select>
                     <select id="cc3" class="easyui-combobox" name="hostPower.hpstart" style="width:110px;">
                         <option value="">星推荐</option>
                         <option value="是">是</option>
                         <option value="否">否</option>
                     </select>
                     <select id="cc4" class="easyui-combobox" name="hostPower.hpdiscount" style="width:110px;">
                         <option value="0">折扣</option>
                         <option value="6">六折</option>
                         <option value="7">七折</option>
                         <option value="8">八折</option>
                         <option value="9">九折</option>
                     </select>

                     <a id="btn1" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="margin-left: 30px">查询</a>

                     <a id="btn2" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'">导出</a>
                 </form>

             </div>
              <%--底部信息展示位置--%>
              <div style="width: 750px;height: 400px;border: 0px solid red;margin: 0px auto;margin-top: 30px">

                  <table id="dg" style="width: 750px;height: 400px"></table>

                  <%--工具栏设置--%>
                  <div id="tb">
                      <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newzhc()">添加主持人</a>
                      <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="zcrStatus()">账号状态</a>
                      <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="zcrRoleB()">权限批量操作</a>
                  </div>
              </div>
              <%--添加主持人信息对话框的展示--%>
             <div id="dlg" class="easyui-dialog" style="width:400px" data-options="closed:true,modal:true,border:'thin',buttons:'#dlg-buttons'">
                     <form id="fm" method="post" novalidate style="margin:0;padding:20px 50px">
                         <h3>User Information</h3>
                         <div style="margin-bottom:10px">
                             <input name="hname" class="easyui-textbox" required="true" label="主持人姓名:" style="width:100%">
                         </div>
                         <div style="margin-bottom:10px">
                             <input name="hpwd" class="easyui-textbox" required="true" label="主持人密码:" style="width:100%">
                         </div>
                         <div style="margin-bottom:10px">
                             <input name="hphone" class="easyui-textbox" required="true" label="主持人电话:" style="width:100%">
                         </div>
                     </form>
             </div>
             <div id="dlg-buttons">
                     <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="savezhr()" style="width:90px">Save</a>
                     <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
             </div>


             <%--主持人授权的对话框的展示--%>
             <div id="zcr_dlg" class="easyui-dialog" style="width:600px" data-options="closed:true,modal:true,border:'thin',buttons:'#zcr_dlg-buttons'">
                 <form id="zcr_fm" method="post" novalidate style="margin:0;padding:20px 50px">
                     <h3>User Information</h3>
                     <div style="margin-bottom:10px">
                         是否星推荐
                         <input class="easyui-radiobutton" name="hpstart" value="是" label="是:">
                         <input class="easyui-radiobutton" name="hpstart" value="否" label="否:">
                     </div>
                     <div style="margin-bottom:10px">
                         星推荐日期
                         <input name="hpstartBeigindate" class="easyui-textbox"    style="width:35%">-

                         <input name="hpstartEnddate" class="easyui-textbox" style="width:35%">
                     </div>
                     <div style="margin-bottom:10px">
                         是否自添加
                         <input class="easyui-radiobutton" name="hpOrderPower" value="是" label="是:">
                         <input class="easyui-radiobutton" name="hpOrderPower" value="否" label="否:">
                     </div>
                     <div style="margin-bottom:10px">
                         星推荐时间
                         <input name="hpstartBegintime" class="easyui-textbox"   style="width:35%">-

                         <input name="hpstartEndtime" class="easyui-textbox" style="width:35%">
                     </div>
                     <div style="margin-bottom:10px">
                         折扣价值&nbsp;&nbsp;&nbsp;
                         <input name="hpdiscount" class="easyui-textbox"  style="width:73%">
                     </div>

                     <div style="margin-bottom:10px">
                         折扣时间&nbsp;&nbsp;&nbsp;
                         <input name="hpDisStarttime" class="easyui-textbox" style="width:35%">-

                         <input name="hpDisEndtime" class="easyui-textbox" style="width:35%">
                     </div>
                     <div style="margin-bottom:10px">
                         主持人价格
                         <input name="hpprice" class="easyui-textbox"   style="width:73%">
                     </div>
                     <div style="margin-bottom:10px">
                         平台管理费
                         <input name="hcosts" class="easyui-textbox"  style="width:73%">
                     </div>
                 </form>
             </div>
             <div id="zcr_dlg-buttons">
                 <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveZcrRole()" style="width:90px">Save</a>
                 <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
             </div>

             <%--主持人状态的对话框的展示--%>
             <div id="zcrStatus_dlg" class="easyui-dialog" style="width:450px" data-options="closed:true,modal:true,border:'thin',buttons:'#zcrStatus_dlg-buttons'">
                 <form id="zcrStatus_fm" method="post" novalidate style="margin:0;padding:20px 50px">
                     <h3>修改账号状态</h3>
                     <div style="margin-bottom:10px">
                         账号状态
                         <input class="easyui-radiobutton" name="status" value="正常" label="正常:">
                         <input class="easyui-radiobutton" name="status" value="禁用" label="禁用:">
                     </div>

                 </form>
             </div>
             <div id="zcrStatus_dlg-buttons">
                 <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveZcrStastus()" style="width:90px">Save</a>
                 <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
             </div>

   </div>

</body>
</html>
